import { Controller, Inject, Get, Query, Post, Param, Del } from '@midwayjs/core';
import { JobLogService } from "@service/monitor/jobLog.service";
import { ListJobLogDTO } from "@dto/monitor/jobLog.dto";
import { Auth } from "@decorator/auth.decorator";
import { BusinessType, Log } from "@decorator/log.decorator";

@Controller('/monitor/jobLog')
export class PostController {
  @Inject()
  jobLogService: JobLogService;

  // 获取列表
  @Auth('monitor:jobLog:list')
  @Get('/list')
  async list(@Query() queryParams: ListJobLogDTO) {
    return await this.jobLogService.list(queryParams);
  }

  // 删除
  @Auth('monitor:jobLog:remove')
  @Log({ title: '定时任务日志', businessType: BusinessType.REMOVE })
  @Del('/:jobLogId')
  async delete(@Param('jobLogId') jobLogId: string) {
    return await this.jobLogService.delete(jobLogId);
  }

  // 获取详情
  @Auth('monitor:jobLog:query')
  @Get('/:jobLogId')
  async get(@Param('jobLogId') jobLogId: number) {
    return await this.jobLogService.detail(jobLogId);
  }

  // 导出
  @Auth('monitor:jobLog:export')
  @Log({ title: '定时任务日志', businessType: BusinessType.EXPORT })
  @Post('/export')
  async export(@Query() queryParams: ListJobLogDTO) {
    return await this.jobLogService.export(queryParams);
  }
}
